import request from '@/utils/request';
import httpRequest from '@/utils/httpRequest';

//获取当前用户接口
export function getUserInfoAPI () {
    return request({
        url:"/api/users/current",
        method:"get"
    })
}

//获取设备列表接口
export function getDeviceAPI (workshop) {
    return request({
        url:"/assemblyReports/devices/" + workshop,
        method:"get"
    })
}
export function reqDeviceInfo (deviceCode) {
    return request({
        url:"/api/device/pages",
        method:"get",
        params:{
            deviceCode
        }
    })
}


//通过订单编号查询产品信息
export function reqProductOrder (orderNum) {
    return request({
        url:"/dfsProductOrder/detail",
        method:"get",
        params:{
            productOrderNumber:orderNum
        }
    })
}

//通过物料号查询数据
export function reqMaterialsInfo (materialsCode) {
    return request({
        url:"/dfsMaterials/code/find",
        method:"get",
        params:{
            code:materialsCode
        }
    })
}

//查询线体信息
// export function reqLineList () {
//     return request ({
//         url:"/api/workCenters/lists",
//         method:"get"
//     })
// }

//通过物料号查询批次号
export function reqBatchCode (materialsCode) {
    return request({
        url:"/dfsStock/stocks/inventory",
        method:"get",
        params:{
            codes:materialsCode
        }
    })
}

//workOrder2 20240921

//保存工单所有数据
export function reqSaveData (data) {
    return request({
        url:"/assemblyReports/saveOrUpdateAll",
        method:"post",
        data:[data]
    })
}

//获取工单报工前判断当前订单、工序下的订单计划剩余数量
export function reqOrderResidueCount (parameter) {
    return request({
        url:"/assemblyReports/findOrderCount",
        method:"get",
        params:parameter
    })
}

//获取当前用户
export function reqUserInfo () {
    return request({
        url:"/api/users/current",
        method:"get"
    })
}

//查询物料信息(品名)
export function reqMeteriaBomInfo (materialCode) {
    return request({
        url:"/api/boms/multiLevel",
        method:"get",
        params:{
            materialCode
        }
    })
}

//根据物料编码查询生产订单列表信息
export function reqProductOrderList (materialCode) {
    return request({
        url:"/api/productOrders/list",
        method:"get",
        params:{
            materialCode,
            state:2  //2
        }
    })
}

//根据订单编号查询订单信息
export function reqProductOrderInfo (productOrderNumber) {
    return request({
        url:"/api/productOrders/list",
        method:"get",
        params:{
            productOrderNumber
        }
    })
}

//查询当天的相关订单
export function reqProductOrderOfDay (planProductStartTime){
    return request({
        url:"/api/productOrders/list",
        method:"get",
        params:{
            planProductStartTime
        }
    })
}
//根据选择设备所在车间查询物料和订单信息(机加工)
export function reqMaterialInfoAndProductInfoByGid (gid) {
    return request({
        url:"/assemblyReports/orders/" + gid,
        method:"get"
    })
}



//分页查询报工列表信息
export function reqWorkOrderList (parameters) {
    return request({
        url:"/assemblyReports/pages",
        method:"get",
        params:parameters
    })
}

//获取班次信息
export function reqClassesList () {
    return request ({
        url:"/api/shifts/list",
        method:"get"
    })
}

//导出报工工单列表信息接口
export function reqExportReportsWorkOrder (parameter) {
    return request ({
        url:"/assemblyReports/export",
        method:"get",
        responseType:"blob",
        params:parameter
    })
}

//通过审核
export function reqCheckPass (data) {
    return request ({
        url:"/assemblyReports/approved",
        method:"post",
        data:data
    })
}

//批量通过审核
export function reqCheckPassBatch (data){
    return request({
        url:"/assemblyReports/approvedSuccessBatch",
        method:"post",
        data:data
    })
}

//判断是否为班组
export function reqCheckIsTeam () {
    return request({
        url:"/assemblyReports/isTeam",
        method:"get"
    })
}

//根据产线查询生产工序
export function reqProcessByLine (lineModelNames){
    return request({
        url:"/api/procedures/list",
        method:"get",
        params:{
            procedureSearch:lineModelNames
        }
    })
}

//获取线体信息
export function reqLineList () {
    return request({
        url:"/api/procedures/list",
        method:"get"
    })
}

//20241008
//查询仓库信息接口
export function reqWareHouseInfo () {
    return request ({
        url:"/assemblyReports/warehouses/2",
        method:"get"
    })
}

//20241015
//根据物料编码查询工序用料信息
export function reqProcessMaterialList(materialCode) {
    return request({
        url:"/assemblyReports/processMaterialList/" + materialCode,
        method:"get"
    })
}
//根据工序id查询其对应工序的用料信息
export function reqProcessMaterialListByProcedureId ({procedureId,materialCode}) {
    return request({
        url:"/assemblyReports/processMaterialListByProcedureId",
        method:"get",
        params:{
            id:procedureId,
            productCode:materialCode
        }
    })
}
//根据物料号查询工序信息
export function reqProcessListByMaterialCode (materialCode) {
    return request({
        url:"/assemblyReports/procedureListByProductCode/" + materialCode,
        method:"get"
    })
}

//20241017
//分页查询生产入库单
export function reqStockInList(page, size) {
    return request({
        url:"/assemblyReports/stockInList",
        method:"get",
        params:{
            page,
            size
        }
    })
}
//根据物料编码分页查询生产入库单
export function reqStockInListByMaterialCode (page, size, materialCode) {
    return request({
        url:"/assemblyReports/stockListByProductCode",
        method:"get",
        params:{
            page,
            size,
            productCode:materialCode
        }
    })
}

//20241022
//仓库审核入库接口
export function reqUpdateStockIn(stockId){
    return request ({
        url:"/assemblyReports/updateStockIn/" + stockId,
        method:"post"
    })
}

//20241018
//查询班组列表信息
export function reqClassTeamList () {
    return request ({
        url:"/assemblyReports/teamList",
        method:"get"
    })
}

//20241022
//补料出库订单列表
export function reqSupplementList(page,size){
    return request({
        url:"/assemblyReports/workOrderSupplementList",
        method:"get",
        params:{
            page,
            size
        }
    })
}
//物料号查询补料出库单
export function reqSupplementListByMaterialCode (page,size,materialCode){
    return request({
        url:"/assemblyReports/workOrderSupplementByCode",
        method:"get",
        params:{
            page,
            size,
            productCode:materialCode
        }
    })
}
//补料审核入库接口
export function reqUpdateWorkOrderSupplement (stockId) {
    return request({
        url:"/assemblyReports/updateWorkOrderSupplement/" + stockId,
        method:"post"
    })
}

//2024-11-15
//获取oee报表数据
export function reqOeeStatementList(parameter){
    return request({
        url:"/assemblyReports/oee",
        method:"get",
        params:parameter
    })
}
//OEE报表导出
export function reqOeeStatementExcel(parameter){
    return request ({
        url:"/assemblyReports/oeeExport",
        method:"get",
        params:parameter,
        responseType:"blob"
    })
}
//oee(生产汇总表)更新已查阅
export function reqUpdateOeeStatement(parameter){
    return request({
        url:"/oeeConfirmations",
        method:"post",
        data:parameter
    })
}
//生产汇总表编辑单班工资
export function reqUpdateSalary(salary){
    return request({
        url:"/paceMaintenances/updateSingleShiftWage",
        method:"put",
        data:{
            configValue:salary
        }
    })
}

//2024-11-19
//机器每月产出记录
export const reqMachineOutputForMonth = (parameters) => {
    return request({
        url:"/assemblyReports/sumMachine",
        method:"get",
        params:{
            workShop:parameters.workshop,
            startDate:parameters.startDate,
            endDate:parameters.endDate
        }
    })
}

export const reqMachineOutputForMonthExpot = (workshop,startDate,endDate) => {
    return request({
        url:"/assemblyReports/sumMachineOutputExport",
        method:"get",
        responseType:'blob',
        params:{
            workShop:workshop,
            startDate,
            endDate
        }
    })
}

//报工审核 取消审核
export const reqCancelCheck = (id) => {
    return request({
        url:"/assemblyReports/removeApproved?id=" + id,
        method:"get"
    })
}

//获取当前用户的班次信息
export const reqUserClassInfo = (username) => {
    return request({
        url:"/shiftConfigurations/currentShift?userName=" + username,
        method:"get"
    })
}



//入库审核更新接口
export function reqUpdateInStockCheck(data){
    return request({
        url:"/assemblyReports/updateStockInAndOut",
        method:"put",
        data:data
    })
}

//分页获取供应商列表
export function reqSupplierList(parameter){
    return request({
        url:"/assemblyReports/supplier/pages",
        method:"get",
        params:{ page:1,size:500,...parameter }
    })
}

//发那特生产日报
export function reqProductionDailyReport(parameter){
    return request({
        url:"/reports/day/report/v1",
        method:"get",
        params:parameter
    })
}

export function reqProductionDailyReportExport(parameter){
    return request({
        url:"/reports/day/report/v1/export",
        method:"get",
        params:parameter,
        responseType:"blob"
    })
}

//发那特生产计件报表
export function reqProductionPieceworkReport(parameter){
    return request({
        url:"/assemblyReports/piecework/report",
        method:"get",
        params:parameter
    })
}

export function reqProductionPieceworkReportExport(parameter){
    return request({
        url:"/assemblyReports/piecework/report/export",
        method:"get",
        params:parameter,
        responseType:"blob"
    })
}

//获取物料列表信息
export function reqMaterialList(parameter){
  return request({
    url:"/assemblyLineMaterialConfigs/material/list",
    method:"get",
    params:parameter
  })
}

//产线关联物料配置
export function reqLineMaterialConfig(parameter){
  return request({
    url:"/assemblyLineMaterialConfigs/pages",
    method:"get",
    params:parameter
  })
}
export function reqLineMaterialConfigById(id){
  return request({
    url:"/assemblyLineMaterialConfigs/" + id,
    method:"get"
  })
}
export function reqDeleteLineMaterialConfig(id){
  return request({
    url:"/assemblyLineMaterialConfigs/" + id,
    method:"delete"
  })
}
export function reqLineMaterialConfigUpdate(data){
  return request({
    url:"/assemblyLineMaterialConfigs/saveOrUpdateAll",
    method:"post",
    data:data
  })
}
//获取工作中心和产线信息
export function reqWorkCenterLineList(data){
    return request({
        url:"/api/production_line/list ",
        method:"post",
        data
    })
}


//装配报工获取所有产线
export function reqAllLineList(){
    return request({
        url:"/assemblyLineMaterialConfigs/lines",
        method:"get"
    })
}
//装配报工选择产线获取对应物料信息
export function reqLineMaterialList(lineName){
    return request({
        url:"assemblyLineMaterialConfigs/line/materialCodes?productionBasicUnitNickName=" + lineName,
        method:"get"
    })
}